from common.base_api import BaseApi
from common.wrapper import api_call


class AuthApi(BaseApi):

    @api_call
    def code_api(self):
        """
        获取图形验证码的sign
        :return:
        """
        api = self.conf_data['api']['auth']['code']
        data = {
            'url': self.host + api,
            'method': 'get',
            'headers': self.headers,
            'json': {}
        }
        response = self.send_http(data)
        return response

    @api_call
    def mobile_pwd_api(self, mobile: str, password: str, picSign: str, picCode: str):
        """
        用户登录： 手机号+密码
        :param mobile: 手机号 必须
        :param password: 密码 必须
        :param picSign: 生成图片验证码时的sign 必须
        :param picCode: 图片验证码 必须
        :return:
            1.code: number 必须
            2.message: string 必须
            3.data: object 必须
        """

        api = self.conf_data['api']['auth']['mobile_pwd']
        data = {
            'url': self.host + api,
            'method': 'post',
            'headers': self.headers,
            'json': {
                "mobile": mobile,
                "password": password,
                "picSign": picSign,
                "picCode": picCode
            }
        }
        response = self.send_http(data)
        return response

    @api_call
    def mobile_sms_code_api(self, mobile: str, checkCode: str):
        """
        用户登录：手机号+验证码
        :param mobile: 手机号，必须
        :param checkCode: 短信验证码 必须
        :return:
            1.code:number 必须
            2.message：string 必须
            3.data:object 必须
        """
        api = self.conf_data['api']['auth']['mobile-sms-code']
        data = {
            'url': self.host + api,
            'method': 'post',
            'headers': self.headers,
            'json': {
                "mobile": mobile,
                "checkCode": checkCode
            }
        }
        response = self.send_http(data)
        return response

    @api_call
    def reset_api(self, mobile: str, password: str, checkCode: str):

        """
        用户重置密码
        :param mobile:手机号 必须
        :param password: 密码  必须
        :param checkCode: 短信验证码 必须
        :return:
        """
        pass
